<!doctype html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<link rel="stylesheet" href="../res/css/weui.css"/>
<link rel="stylesheet" href="../res/css/weuix.css"/>
<link rel="stylesheet" href="../res/css/common.css" />
<script src="../res/js/zepto.min.js"></script>
<script src="../res/js/zepto.weui.js"></script>
<script src="../res/js/common.js?v=1"></script>
<link rel="stylesheet" href="https://cdn.bootcss.com/weui/1.1.3/style/weui.min.css">
<script src="" type="text/javascript" charset="utf-8"></script>
<script>
	var doctor_id = getQst("doctor_id");
	var online,onlinelist='',doctor_name='',userJson='',doctorList='';
	var haveFee = 0,haveFeeDoctorName='',haveFeeLogType=0,h5token='',userid = '',usertype='';
    // var doctor_id = "346";
	function showDoctor() {
		userJson = getUserInfo();
		h5token = userJson.h5Token
		userid = userJson.id;
		usertype = userJson.type;
        var paramJson = { 
			"id": doctor_id, 
		};
        newAjaxPost("/h5/doctorInfo/getDoctorInfo", paramJson, showDoctorOk);
        return false;
    }

	function latershowDoctor() {
	    var paramJson = { 
			"id": parseInt(doctor_id), 
		};
		newAjaxPost("/h5/doctorInfo/getDoctorInfo", paramJson, latershowDoctorOk);
	    // ajaxPost("publicUtil_getDoctorInfoListH5", paramJson, latershowDoctorOk);
	    return false;
	}
	
	function latershowDoctorOk(jsonInfo) {
		console.log(jsonInfo);
		console.log(jsonInfo,"latershowDoctorOk");
		doctorList = jsonInfo.data; //3获取医生列表
	    var doctorListData = '';
		var lateronline,lateronlinelist = '';

	    if (doctorList.isOnline == 1) {//是否在线  0否  1是
			lateronline='在线';
			var online_img= '<img src="../res/images/img_on_line.png">'
			lateronlinelist+='<button style="background-color:#ffffff;" class="schedulingBtn" id="' + doctor_id + '"><p>值班时间<p></button>'
			// lateronlinelist='<button class="inquiryBtn" style="background-color:#1189ff;" num="1" id="' + doctor_id + '" docname="'+doctorList.trueName+'" pay="'+doctorList.videoInterrogation+'"><p>视频问诊<p></button>'
			// lateronlinelist='<button class="inquiryBtn" style="background-color:#1189FF;" num="2" id="' + doctor_id + '" docname="'+doctorList.trueName+'" pay="'+doctorList.textInterrogation+'" ><p>图文问诊<p></button>'
			if(doctorList.inquiryType == 3){				//全部问诊
				lateronlinelist+='<button class="inquiryBtn" style="background-color:#1189ff;" num="1" id="' + doctor_id + '" docname="'+doctorList.trueName+'" pay="'+doctorList.videoInterrogation+'"><p>视频问诊<p></button>'
				lateronlinelist+='<button class="inquiryBtn" style="background-color:#1189FF;" num="2" id="' + doctor_id + '" docname="'+doctorList.trueName+'" pay="'+doctorList.textInterrogation+'" ><p>图文问诊<p></button>'
			}else if(doctorList.inquiryType == 1){			//视频问诊
				lateronlinelist+='<button class="inquiryBtn" style="background-color:#1189ff;" num="1" id="' + doctor_id + '" docname="'+doctorList.trueName+'" pay="'+doctorList.videoInterrogation+'"><p>视频问诊<p></button>'
				lateronlinelist+='<button style="background-color:#D9D9D9;"><p>视频问诊<p></button>'
			}else if(doctorList.inquiryType == 2){										//图文问诊
				lateronlinelist+='<button style="background-color:#D9D9D9;"><p>图文问诊<p></button>'
				lateronlinelist+='<button class="inquiryBtn" style="background-color:#1189FF;" num="2" id="' + doctor_id + '" docname="'+doctorList.trueName+'" pay="'+doctorList.textInterrogation+'" ><p>图文问诊<p></button>'
			}
		}else {
			lateronline='离线';
			var online_img= '<img src="../res/images/img_off_line.png">'
			lateronlinelist='<button style="background-color:#ffffff;" class="schedulingBtn" id="' + doctor_id + '"><p>值班时间</p></button><button style="background-color:#1189ff;" id="showIOSDialog1" ><p>视频问诊</p></button><button style="background-color:#1189FF;"  id="showIOSDialog2" ><p>图文问诊</p></button>';
		}
		if(lateronline==online){
			//在线状态不变
			$('.btn').html(lateronlinelist)
		}else{
			online=lateronline
			$('.is_online').html(online_img)
			$('.btn').html(lateronlinelist)
		}
		$('#showIOSDialog1').on('tap', function(){
		    // $iosDialog1.fadeIn(200);
			$.alert({
				title: '温馨提示',
				text: '当前医生离线，请选择其他医生',
				onOK: function () {
					//点击确认
				}
			});
		});
		$('#showIOSDialog2').on('tap', function(){
		    $.alert({
		        title: '温馨提示',
		        text: '当前医生离线，请选择其他医生',
		        onOK: function () {
		            //点击确认
		        }
		    });
		});
		setTimeout(function () {
		    latershowDoctor();
		}, 10000);
	}
    function showDoctorOk(jsonInfo) {
		console.log(jsonInfo,"showDoctorOk");
		doctorList = jsonInfo.data; //3获取医生列表
        var doctorListData = '';
		getCommitOK(doctorList.doctorEvaluate)
		doctor_name=doctorList.trueName
		if (doctorList.isOnline == 1) {//是否在线  0否  1是
			online='../res/images/img_on_line.png';
			onlinelist+='<div class="btn"><button style="background-color:#ffffff;" class="schedulingBtn" id="' + doctor_id + '"><p>值班时间<p></button>'
			// lateronlinelist='<button class="inquiryBtn" style="background-color:#1189ff;" num="1" id="' + doctor_id + '" docname="'+doctorList.trueName+'" pay="'+doctorList.videoInterrogation+'"><p>视频问诊<p></button>'
			// lateronlinelist='<button class="inquiryBtn" style="background-color:#1189FF;" num="2" id="' + doctor_id + '" docname="'+doctorList.trueName+'" pay="'+doctorList.textInterrogation+'" ><p>图文问诊<p></button>'
			if(doctorList.inquiryType == 3){				//全部问诊
				onlinelist+='<button class="inquiryBtn" style="background-color:#1189ff;" num="1" id="' + doctor_id + '" docname="'+doctorList.trueName+'" pay="'+doctorList.videoInterrogation+'"><p>视频问诊<p></button>'
				onlinelist+='<button class="inquiryBtn" style="background-color:#1189FF;" num="2" id="' + doctor_id + '" docname="'+doctorList.trueName+'" pay="'+doctorList.textInterrogation+'" ><p>图文问诊<p></button></div>'
			}else if(doctorList.inquiryType == 1){			//视频问诊
				onlinelist+='<button class="inquiryBtn" style="background-color:#1189ff;" num="1" id="' + doctor_id + '" docname="'+doctorList.trueName+'" pay="'+doctorList.videoInterrogation+'"><p>视频问诊<p></button>'
				onlinelist+='<button style="background-color:#D9D9D9;"><p>视频问诊<p></button></div>'
			}else{										//图文问诊
				onlinelist+='<button style="background-color:#D9D9D9;"><p>图文问诊<p></button>'
				onlinelist+='<button class="inquiryBtn" style="background-color:#1189FF;" num="2" id="' + doctor_id + '" docname="'+doctorList.trueName+'" pay="'+doctorList.textInterrogation+'" ><p>图文问诊<p></button></div>'
			}
		}else {
			online='../res/images/img_off_line.png';
			onlinelist=	'<div class="btn"><button style="background-color:#ffffff;" class="schedulingBtn" id="' + doctor_id + '"><p>值班时间</p></button><button style="background-color:#1189ff;" id="showIOSDialog1" ><p>视频问诊</p></button><button style="background-color:#1189FF;"  id="showIOSDialog2" ><p>图文问诊</p></button></div>';
		}
					
		doctorListData += '<div class="doctor_info">';
		doctorListData += '	<div class="is_online"><img src="'+online+'"></div>';
		doctorListData += '	<div class="expertlist_map_top">';
		doctorListData += '		<div class="expertlist_map_img"> <img src="' + doctorList.doctorHeadImg + '"> </div>';
		doctorListData += '		<div class="doctor_info1">';
		doctorListData += '			<div class="doctor_name">' + doctorList.trueName + '<span>' + doctorList.doctorJobTitle + '</span>   <span>' + doctorList.departmentName + '</span></div>';
		doctorListData += '			<div class="age">限 <span>' + doctorList.workAge + '年</span> 　年龄 <span>' + doctorList.doctorAge + '岁</span></div>';
		doctorListData += '		</div>';
		doctorListData += '	</div>    ';
		doctorListData += '	<div class="brief_introduction" style="color:#353535;">' + doctorList.doctorSynopsis + '</div>';
		doctorListData += '	<div class="line"><div></div><div></div></div>';
		doctorListData += '	<div class="brief_introduction" style="color:#353535;">擅长：<span>' + doctorList.doctorSpecialty +'</span></div>';
		doctorListData += '	<div class="brief_introduction" style="color:#757575;">执业医院：' + doctorList.hospitalName + '</div>';
		doctorListData += '</div>';
				
        $('#doctorList').html(doctorListData);
		$('.btn_group').html(onlinelist);
        setTimeout(function () {
            latershowDoctor();
        }, 10000);
    }
	
	function getCommitOK(data){
		let commitList = [];
			var limit = 0;
			if(data.length>10){
				limit = 10;
			}else{limit = data.length}
			if(data.length>0){
				for(var i=0;i<limit;i++){
					if(data[i].patientName==null){
						data[i].patientName='匿名'
					}
					if(data[i].evaluateStr=='非常满意'){
						commitList+='<div class="info_content"><div class="info_isonline">'+data[i].patientName+'</div><div class="info_com vg">非常满意</div><div class="info_time">'+data[i].createTime+'</div></div>'
					}else if(data[i].evaluateStr=='满意'){
						commitList+='<div class="info_content"><div class="info_isonline">'+data[i].patientName+'</div><div class="info_com og">满意</div><div class="info_time">'+data[i].createTime+'</div></div>'
					}else if(data[i].evaluateStr=='基本满意'){
						commitList+='<div class="info_content"><div class="info_isonline">'+data[i].patientName+'</div><div class="info_com sg">基本满意</div><div class="info_time">'+data[i].createTime+'</div></div>'
					}else if(data[i].evaluateStr=='不满意'){
						commitList+='<div class="info_content"><div class="info_isonline">'+data[i].patientName+'</div><div class="info_com ng">不满意</div><div class="info_time">'+data[i].createTime+'</div></div>'
					}
				}
			}else{
				commitList+='<div class="info_content" style="text-align:center">暂无患者评论</div>'
			}
			$('.weui-cells').html(commitList);
	}
	
	function newGetConsultationFee(){
		if (!isLogin()) { //判断是否登录
		    // 不获取
		}else{
			newAjaxPost("/h5/wxpay/getConsultationFee", {}, newGetConsultationFeeOk);
		}
	}
	function newGetConsultationFeeOk(jsonInfo){
		var data,time=null;
		if(jsonInfo.code == 1){
			data = jsonInfo.data;
			if(data){
				haveFee = 1
				haveFeeLogType = data.inquiryType;
				haveFeeDoctorName = data.trueName;
			}else{
				haveFee = 0
			}
		}
	}
	
	//查看医生值班计划
	$(document).on("click", ".schedulingBtn", function () {
		log_type = $(this).attr('num');
		doctor_id = $(this).attr('id');
	    goPage('inquiry_doctor_sche.htm?doctor_id=' + doctor_id+ "&rand=" + Math.random());
	});

    $(function () {
        doctor_id = getQst("doctor_id");
        showDoctor();
		newGetConsultationFee()
		
		//视频、图文问诊
		$(document).on("click", ".inquiryBtn", function () {
		    log_type = $(this).attr('num');
		    doctor_id = $(this).attr('id');
			doctor_name = $(this).attr('docname');
			fee_pay = $(this).attr('pay');
		    if (!isLogin()) { //判断是否登录
		        $.confirm("请先登录再操作", function() {
		        	goPage('login.htm');
		        }, function() {
		        	//取消操作
		        });
		    } else {
				var strGoUrl;
		        if(haveFee==0){									//没付问诊费
		        	strGoUrl = 'inquiry_doctor_fee.htm?feepay=' + fee_pay + '&log_type=' + log_type + '&doctor_id=' + doctor_id + '&doctor_name=' + doctor_name ;
		        	goPage(strGoUrl);
		        }else{											//已付问诊费
		        	if(haveFeeDoctorName==doctor_name&&log_type==haveFeeLogType){			//已付费的那个医生
		        		strGoUrl = 'inquiry_doctor_patient.htm?log_type=' + log_type + '&doctor_id=' + doctor_id + '&h5_token='+h5token + '&user_id=' + userid + '&user_type=' + usertype;
		        		goPage(strGoUrl);
		        	}else if(haveFeeDoctorName==doctor_name&&log_type!=haveFeeLogType){
		        		$.alert("您购买的是该医生的另一种问诊！",function(){
		        			return;
		        		});
		        	}else{										//不是已付费的那个医生，禁止问诊
		        		$.alert("本日之内您还有其他医生的问诊没结束，请先完成问诊！",function(){
		        			return;
		        		});
		        	}
		        }
		    }
		});
		
		$('#btnBack').on("click", function () {
		    history.go(-1);
		});
		$('#showIOSDialog1').on('tap', function(){
		    // $iosDialog1.fadeIn(200);
			$.alert({
				title: '温馨提示',
				text: '当前医生离线，请选择其他医生',
				onOK: function () {
					//点击确认
				}
			});
		});
		$('#showIOSDialog2').on('tap', function(){
		    $.alert({
		        title: '温馨提示',
		        text: '当前医生离线，请选择其他医生',
		        onOK: function () {
		            //点击确认
		        }
		    });
		});
		// 患者评价
		$(document).on("click", "#index_more", function () {
			var strGoUrl = 'inquiry_doctor_commit.htm?doctor_id=' + doctor_id;
			goPage(strGoUrl);
		});
		
    });
</script>
<style>
    .header {  text-align: center;  z-index: 5;  width: 100%;  top: 0;  transition: 0.5s;}
    .doctor-avatar {width: 100px;height: 100px;	border: 1px solid #006400;	border-radius: 50%;	display: block;	margin: 0 auto 0.2933rem;	}
    .interval {	text-align: left;	width: 100%;	border-top: 10px solid #f1f3f4;	text-indent: 5px;	line-height: 30px;	font-weight: bold;}
	.doctorMes {display: flex;flex-direction: column;		justify-content: center;	align-items: center;	}
    .img-wrapper {	box-sizing: border-box;	/*float: left;*/	display: inline-block;	display: inline-flex;	align-items: center;	width: 6rem;	height: 6rem;	margin: 0.2rem 0.25rem;	position: relative;	overflow: hidden;	border-radius: 50%;	}
	img {	width: 100%;	height: 100%;	}
    .fixed-top {  position: fixed; left: 0; top: 0; right: 0; z-index: 5;  }
    .weui-label-s { margin-top: 5px; padding: 5px;font-size: 16px; }
	.btn { display: flex; justify-content: space-around; padding: 5px 0;  }
    .btn>button { border: none; border-radius: 15px; width: 30%; display: flex; flex-direction: column; align-items: center; padding: 8px; outline: none; }
    .btn>button>div {width: 24px; height: 24px;}
	.btn>button:first-child { border: 1px solid #1189ff; }
    .btn>button p { color: white;  }
	.btn>button:first-child p { color: #1189ff;  }
	.weui-btn_primary:not(.weui-btn_disabled):active {
	    background-color: #ffffff;
	}
	.tip { display: flex; justify-content: space-around; padding: 5px 0;  }
	.tips{    font-size: 12px;	padding: 0 5px;    width: 33%;   color: red;}
	
	.weui-btn_primary {
	    background-color: #ffffff;
	}
	.doctor_info{
	    background: #fff;
	    border-radius: 10px;
	    margin: 10px;
	    padding-bottom: 5px;
	}
	.doctor_info1{
		margin-left: 5px;
	}
	.is_online {
	    right: 10px;
	}
	.brief_introduction{
	    font-size: 14px;
	    color: #666;
	    margin: 15px;
	    font-weight: bold;
		padding: 0;
		max-height: unset;
		-webkit-box-orient: unset;
	}
	.brief_introduction span{
	   color: #1189FF;
	}
	.line{display: flex;font-size: 52px;height: 10px;line-height: 9px;color: #F9F8FE;}
	.line div{height: 18px;width: 18px;background: #F9F8FE;border-radius: 18px;margin: 0 1%;position: absolute;}
	.line div:first-child{left: 0px;}
	.line div:last-child{right: 0px;}
	
	.block{ font-size: 14px;margin: 0px 10px;}
	.index_title{ margin: 10px 0; margin-top: 0; padding: 0 5px; font-size: 16px; font-weight: bold; position: relative;display: inline-block;}
	#round1{width: 8px;height: 8px;background-color: #F8B551;color: white;position: absolute;top: 0;border-radius: 6px; z-index: -1;}
	#round2{width: 13px;height: 13px;background-color: #1189FF;color: white;position: absolute;top: 7px;left: 63px;border-radius: 16px;z-index: -1;}
	#index_more{float: right; display: inline-block;margin-top: 4px;}
	.weui-cells{padding: 0 10px;border-radius: 10px;}
	.info_content{
		border-bottom: 1px solid #E0E0E0;
		padding: 10px 0;
	}
	.info_content:last-child{
		border-bottom: 0px;
	}
	.info_isonline{display: inline-block;}
	.info_com{
		color: #1189ff;
		background-color: #ECF6FF;
		display: unset;
		padding: 2px 5px;
		border-radius: 7px;
		margin-left: 10px;
		font-size: 12px;
	}
	.og{color: #4AA95C;background-color: #F1F8F2;}
	.sg{color: #ECA02C;background-color: #FEF8EE;}
	.ng{color: #FA6464;background-color: #FFF3F3;}
	.info_time{
		display: inline-block;
		float: right;
		color: #353535;
	}
	.weui-cells:after {border-bottom: 0px;}
	.btn_group{
		position: fixed;
		bottom: 0;
		width: 100%;
		background-color: #F9F8FE;
	}
</style>
<body ontouchstart style="padding-bottom: 63px;">
    <div class="fixed-top">
    <div class="weui-header weui-btn_primary"> 
        <div class="weui-header-left"><a id="btnBack" class="icon icon-109"></a></div>
        <div class="weui-header-title">专家资料</div>
        <div class="weui-header-right"></div>
    </div>
    </div>
    <div style="margin-top:55px;z-index:-1">
			<div id="doctorList"></div>
    </div>
	<div class="block">
		<div class="index_title"><div id="round1"></div>患者评价 <div id="round2"></div></div>
		<div id="index_more">更多 ></div>
	</div>
	<div class="block weui-cells">
	</div>
	<div class="btn_group">
		
	</div>
</body>
</html>
